package ro.prjmanager.template.form;

import ro.prjmanager.model.*;
import ro.prjmanager.database.model.Table;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class Form {
    private Layers layer;
    private CustomComponents component;
    private Table table;
    private Projects project;
    private Users user;

    private int version;

    private String companyName;
    private String author;
    private String year;
    private String rootPackage;

    private String modelPackage;
    private String daoPackage;
    private String servicePackage;
    private String actionPackage;


    private String refPackage;

    private String relativeToRootPackage;
    private String suffix;
    private String modelSuffix;
    private String daoSuffix;
    private String serviceSuffix;
    private String actionSuffix;


    private String reffSuffix;
    private String guiPath;
    private String guiMenu;


    public Form(Layers layer, CustomComponents component, Table table, Projects project,
                Users user, int version,
                String modelPack,String modelSuffix,
                String daoPack,String daoSuffix,
                String servicePack,String serviceSuffix,
                String actionPack,String actionSuffix
                ) {
        this.layer = layer;
        this.component = component;
        this.table = table;
        this.project = project;
        this.user = user;
        this.version = version;
        this.companyName=project.getCompanyName();
        this.author=user.getFirstName()+" "+user.getLastName();
        Calendar cal = new GregorianCalendar();
        this.year = String.valueOf(cal.get(Calendar.YEAR));
        this.rootPackage=project.getPackageBase();
        this.relativeToRootPackage=component.getFkComponents().getRelativePackage();

        this.modelPackage=modelPack;
        this.servicePackage=servicePack;
        this.daoPackage=daoPack;
        this.actionPackage=actionPack;

        this.modelSuffix=modelPack;
        this.serviceSuffix=serviceSuffix;
        this.daoSuffix=daoSuffix;
        this.actionSuffix=actionSuffix;

        this.suffix=component.getFkComponents().getSuffix();
        this.modelSuffix=modelSuffix;
        if(this.component!=null&&this.component.getComponentDetails()!=null){
            this.guiPath=this.component.getComponentDetails().getGuiPathPreffix();
            this.guiMenu=this.component.getComponentDetails().getGuiMenuPreffix();
        }

    }

    public Layers getLayer() {
        return layer;
    }

    public void setLayer(Layers layer) {
        this.layer = layer;
    }

    public CustomComponents getComponent() {
        return component;
    }

    public void setComponent(CustomComponents component) {
        this.component = component;
    }

    public Table getTable() {
        return table;
    }

    public void setTable(Table table) {
        this.table = table;
    }

    public Projects getProject() {
        return project;
    }

    public void setProject(Projects project) {
        this.project = project;
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getRootPackage() {
        return rootPackage;
    }

    public void setRootPackage(String rootPackage) {
        this.rootPackage = rootPackage;
    }



    public String getRelativeToRootPackage() {
        return relativeToRootPackage;
    }

    public void setRelativeToRootPackage(String relativeToRootPackage) {
        this.relativeToRootPackage = relativeToRootPackage;
    }

    public String getModelPackage() {
        return modelPackage;
    }

    public void setModelPackage(String modelPackage) {
        this.modelPackage = modelPackage;
    }


    public String getRefPackage() {
        return refPackage;
    }

    public void setRefPackage(String refPackage) {
        this.refPackage = refPackage;
    }

    public String getModelSuffix() {
        return modelSuffix;
    }

    public void setModelSuffix(String modelSuffix) {
        this.modelSuffix = modelSuffix;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getReffSuffix() {
        return reffSuffix;
    }

    public void setReffSuffix(String reffSuffix) {
        this.reffSuffix = reffSuffix;
    }

    public String getGuiPath() {
        return guiPath;
    }

    public void setGuiPath(String guiPath) {
        this.guiPath = guiPath;
    }

    public String getGuiMenu() {
        return guiMenu;
    }

    public void setGuiMenu(String guiMenu) {
        this.guiMenu = guiMenu;
    }

    public String getDaoPackage() {
        return daoPackage;
    }

    public void setDaoPackage(String daoPackage) {
        this.daoPackage = daoPackage;
    }

    public String getServicePackage() {
        return servicePackage;
    }

    public void setServicePackage(String servicePackage) {
        this.servicePackage = servicePackage;
    }

    public String getActionPackage() {
        return actionPackage;
    }

    public void setActionPackage(String actionPackage) {
        this.actionPackage = actionPackage;
    }

    public String getDaoSuffix() {
        return daoSuffix;
    }

    public void setDaoSuffix(String daoSuffix) {
        this.daoSuffix = daoSuffix;
    }

    public String getServiceSuffix() {
        return serviceSuffix;
    }

    public void setServiceSuffix(String serviceSuffix) {
        this.serviceSuffix = serviceSuffix;
    }

    public String getActionSuffix() {
        return actionSuffix;
    }

    public void setActionSuffix(String actionSuffix) {
        this.actionSuffix = actionSuffix;
    }

    public String relPak(){
        String actionRelPack=component.getComponentDetails().getActionRelPack();
        String relativeToRootPackageRet=relativeToRootPackage;
        if(actionRelPack!=null)
           relativeToRootPackageRet=relativeToRootPackageRet.substring(relativeToRootPackageRet.indexOf(actionRelPack)+actionRelPack.length()+1);

        return relativeToRootPackageRet!=null&&relativeToRootPackageRet.length()>0?relativeToRootPackageRet.replace(".","/"):"";
    }
}
